In [1]:
#general imports
import pygslib
import pandas as pd
import matplotlib.pyplot as plt
from scipy.stats import norm
import numpy as np
#make the plots inline
#matplotlib notebook
%matplotlib inline
In [2]:
#get the data in gslib format into a pandas Dataframe
clusterdata= pygslib.gslib.read_gslib_file('../datasets/cluster.dat')
clusterdata.head()
Out[2]:
In [3]:
# Fit anamorphosis by changing, zmax, zmin, and extrapolation function
PCI, H, raw, zana, gauss, z, P, raw_var, PCI_var, fig1 = pygslib.nonlinear.anamor(
z = clusterdata['Primary'],
w = clusterdata['Declustering Weight'],
zmin = clusterdata['Primary'].min()-1,
zmax = clusterdata['Primary'].max()+10,
zpmin = None, zpmax = None,
ymin=-5, ymax=5,
ndisc = 5000,
ltail=1, utail=4, ltpar=1, utpar=1.5, K=40)
In [4]:
PCI
Out[4]:
In [5]:
ZV, PV, fig2 = pygslib.nonlinear.anamor_blk( PCI, H, r = 0.7, gauss = gauss, Z = z,
ltail=1, utail=1, ltpar=1, utpar=1,
raw=raw, zana=zana)
In [6]:
# the pair ZV, PV define the CDF in block support
# let's plot the CDFs
plt.semilogx (raw,P, '--k', label = 'exp point' )
plt.semilogx (z,P, '-g', label = 'ana point(fixed)' ) #point support (from gaussian anamorphosis)
plt.semilogx (ZV, PV, '-m', label = 'ana block(fixed)') #block support
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
Out[6]:
In [7]:
cutoff = np.arange(0,10, 0.1)
tt = []
gg = []
label = []
# calculate GTC from gaussian in block support
t,ga,gb = pygslib.nonlinear.gtcurve (cutoff = cutoff, z=ZV, p=PV, varred = 1, ivtyp = 0, zmin = 0, zmax = None,
ltail = 1, ltpar = 1, middle = 1, mpar = 1, utail = 1, utpar = 1,maxdis = 1000)
tt.append(t)
gg.append(ga)
label.append('DGM with block support')
# calculate GTC using undirect lognormal
t,ga,gb = pygslib.nonlinear.gtcurve (cutoff = cutoff, z=z, p=P, varred = 0.4, ivtyp = 2, zmin = 0, zmax = None,
ltail = 1, ltpar = 1, middle = 1, mpar = 1, utail = 1, utpar = 1,maxdis = 1000)
tt.append(t)
gg.append(ga)
label.append('Indirect Lognormal Correction')
# calculate GTC using affine
t,ga,gb = pygslib.nonlinear.gtcurve (cutoff = cutoff, z=z, p=P, varred = 0.4, ivtyp = 1, zmin = 0, zmax = None,
ltail = 1, ltpar = 1, middle = 1, mpar = 1, utail = 1, utpar = 1,maxdis = 1000)
tt.append(t)
gg.append(ga)
label.append('Affine Correction')
# calculate GTC in point support
t,ga,gb = pygslib.nonlinear.gtcurve (cutoff = cutoff, z=z, p=P, varred = 1, ivtyp = 2, zmin = 0, zmax = None,
ltail = 1, ltpar = 1, middle = 1, mpar = 1, utail = 1, utpar = 1,maxdis = 1000)
tt.append(t)
gg.append(ga)
label.append('Point (anamorphosis without support effect)')
In [8]:
fig = pygslib.nonlinear.plotgt(cutoff = cutoff, t = tt, g = gg, label = label)
In [9]:
PCI, H, raw, zana, gauss, raw_var, PCI_var, fig3 = pygslib.nonlinear.anamor_raw(
z = clusterdata['Primary'],
w = clusterdata['Declustering Weight'],
K=40)
In [ ]:
In [ ]: